import { articleControllerFindOne } from "@/app/servers/api/article";
import Detail from "./detail";
import { articleViewControllerCreate } from "@/app/servers/api/articleView";
import { cookies, headers } from "next/headers";

export default async function ArticleDetailPage({
  params,
}: {
  params: { id: string };
}) {
  const { data } = await articleControllerFindOne(
    {
      id: params.id,
    },
    {
      next: {
        headers: headers(),
        cookies: cookies(),
      },
    }
  );
  articleViewControllerCreate(
    {
      articleId: parseInt(params.id),
    },
    {
      next: {
        headers: headers(),
        cookies: cookies(),
      },
    }
  );
  return <Detail article={data} />;
}
